﻿using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace Electronic_work_order.Model
{
    public static class ModelBuilderExtensions
    {
        public static void Seed(this ModelBuilder modelBuilder)
        {
            //添加组织表
            modelBuilder.Entity<Organization>().HasData(
                new Organization {OrganizationID=1,OrganizationName="OA办公",OrganizationPhone="123456781",ParentId=0,Remarks="" },
                new Organization {OrganizationID=2, OrganizationName = "人事部", OrganizationPhone = "123456782", ParentId = 1, Remarks = "" },
                new Organization { OrganizationID = 3, OrganizationName = "行政部", OrganizationPhone = "123456783", ParentId = 1, Remarks = "" },
                new Organization { OrganizationID = 4, OrganizationName = "客户部", OrganizationPhone = "123456784", ParentId = 1, Remarks = "" },
                new Organization { OrganizationID = 5, OrganizationName = "采购部", OrganizationPhone = "123456785", ParentId = 1, Remarks = "" }
                                 );


            //添加人员数据
            modelBuilder.Entity<Users>().HasData(
                new Users { UsersID = 1 , UsersName="周艳玲",UsersPwd="123456",UsersSex="女",UsersPhone="13728491578",UsersEmail="abc1@qq.com",OrganizationID=1, RoleID = 3,EntryTime=DateTime.Now,QuitTime="",StateID=1,Remarks=""},
                new Users { UsersID =2, UsersName = "雷晴晴", UsersPwd = "123456", UsersSex = "女", UsersPhone = "13728491579", UsersEmail = "abc2@qq.com", OrganizationID = 2, RoleID = 2, EntryTime = DateTime.Now, QuitTime = "", StateID = 1, Remarks = "" },
                new Users { UsersID = 3, UsersName = "陈臣", UsersPwd = "123456", UsersSex = "男", UsersPhone = "13728491576", UsersEmail = "abc3@qq.com", OrganizationID = 3, RoleID = 2, EntryTime = DateTime.Now, QuitTime = "", StateID = 1, Remarks = "" },
                new Users { UsersID = 4, UsersName = "杨思航", UsersPwd = "123456", UsersSex = "女", UsersPhone = "13728491575", UsersEmail = "abc4@qq.com", OrganizationID = 4, RoleID = 1, EntryTime = DateTime.Now, QuitTime = "", StateID = 1, Remarks = "" }
                ) ;
            //给状态表添加数据
            modelBuilder.Entity<UserState>().HasData(
                new UserState {StateID=1,StateName="在职" },
                new UserState { StateID = 2, StateName = "离职" },
                new UserState { StateID = 3, StateName = "有效" },
                new UserState { StateID = 4, StateName = "无效" },
                new UserState { StateID = 5, StateName = "启用" },
                new UserState { StateID = 6, StateName = "禁用" }


                );


            //添加职位表
            modelBuilder.Entity<Position>().HasData(
                new Position {PositionID=1,PositionName= "人力资源总监", OrganizationID=2,Comments="",Update_date=DateTime.Now },
                new Position { PositionID = 2, PositionName = "人力资源经理", OrganizationID = 2, Comments = "", Update_date = DateTime.Now },
                new Position { PositionID = 3, PositionName = "招聘主管", OrganizationID = 2,  Comments = "", Update_date = DateTime.Now },
                new Position { PositionID = 4, PositionName = "行政部部长", OrganizationID = 3, Comments = "", Update_date = DateTime.Now },
                new Position { PositionID = 5, PositionName = "后勤管理员", OrganizationID = 3,  Comments = "", Update_date = DateTime.Now },
                new Position { PositionID = 6, PositionName = "行政专管", OrganizationID = 3, Comments = "", Update_date = DateTime.Now },
                new Position { PositionID = 7, PositionName = "客户总监", OrganizationID = 4,   Comments = "", Update_date = DateTime.Now },
                new Position { PositionID = 8, PositionName = "客户经理经理", OrganizationID = 4,  Comments = "", Update_date = DateTime.Now },
                new Position { PositionID = 10, PositionName = "采购总经理", OrganizationID = 5, Comments = "", Update_date = DateTime.Now },
                new Position { PositionID = 11, PositionName = "采购主管", OrganizationID = 5, Comments = "", Update_date = DateTime.Now },
                new Position { PositionID = 12, PositionName = "董事长", OrganizationID = 1,  Comments = "", Update_date = DateTime.Now }
            );

            modelBuilder.Entity<UserRole>().HasData(
                new UserRole{RoleID=1,RoleName="普通职员",StateID=5,CreateTime=DateTime.Now},
                new UserRole { RoleID = 2, RoleName = "经理", StateID = 5, CreateTime = DateTime.Now },
                new UserRole { RoleID = 3, RoleName = "老板", StateID = 5, CreateTime = DateTime.Now }
                );
           
        }
    }
}
